<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><%=UserUtil.getCurrentMenuItemName() %></title>
    
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.bgiframe-2.1.2.js'/>"></script>
    
    <script type="text/javascript">
    <!-- 
    $(document).ready(function() {    
        $('#doAddBtn').click(function() {
            waitingDialog({});
            $.ajax({url : "<c:url value='/ajax/Soez9003.action'/>",
                async : true,
                type : 'POST',
                data : $("#addMenuHiddenFrom").serialize(),
                dataType : 'html',
                success : function(data, textStatus, XMLHttpRequest){
                        $("#menuItemDiv").html(data);
                        $("#menuItemDiv" ).dialog({  
                            title:'權限功能資料' 
                            ,width: 600
                            , resizable: false
                            , modal: true
                        });
                    },
                error : function(XMLHttpRequest, textStatus, errorThrown){
                        $("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
                        $("#ajaxErrorMessageDiv" ).dialog({  
                            title:'系統錯誤' 
                            ,width: 600
                            , resizable: false
                            , modal: true
                            , buttons: {
                                Ok: function() {
                                    $( this ).dialog( "close" );
                                }
                            }
                        });
                    },
                complete: function(XMLHttpRequest, textStatus){closeWaitingDialog();}
            });
        });                  
    });
    
    $(document).ready(function() {    
        $('#doQueryBtn').click(function() {
        	var menuType = $('#menuType').val();
        	var menuId = $('#menuId').val();
        	var actionName = $('#actionName').val();
        	
            $('#hidden\\.menuType').val(menuType);
            $('#hidden\\.menuId').val(menuId);
            $('#hidden\\.actionName').val(actionName);
                
            doQueryAction(1);
        });                  
    });    
    
    function doQueryAction(pageNumber)
    {
        if (null != pageNumber)
            $('#hidden\\.queryResult\\.pageNumber').val(pageNumber);
        
        $("#queryResultDiv").fadeTo("slow", 0.1);

        waitingDialog({});
        $.ajax({url : "<c:url value='/ajax/Soez9003.action'/>",
            async : true,
            type : 'POST',
            data : $("#queryHiddenFrom").serialize(),
            dataType : 'html',
            success : function(data, textStatus, XMLHttpRequest){
                    $("#queryResultDiv").html(data);
                },
            error : function(XMLHttpRequest, textStatus, errorThrown){
                $("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
                $("#ajaxErrorMessageDiv" ).dialog( "destroy" );
                $("#ajaxErrorMessageDiv" ).dialog({  
                    title:'系統錯誤' 
                    ,width: 600
                    , resizable: false
                    , modal: true
                    , buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
                },
            complete: function(XMLHttpRequest, textStatus){
                $("#queryResultDiv").fadeTo("slow", 1);
                closeWaitingDialog();
            }
        });;
    }       
    
    function doQueryMenuAction(menuItemPk)
    {
        $('#hidden\\.menuItemPk').val(menuItemPk);

        waitingDialog({});
        $.ajax({url : "<c:url value='/ajax/Soez9003.action'/>",
            async : true,
            type : 'POST',
            data : $("#queryMenuHiddenFrom").serialize(),
            dataType : 'html',
            success : function(data, textStatus, XMLHttpRequest){
                    $("#menuItemDiv").html(data);
                    $("#menuItemDiv" ).dialog({  
                        title:'權限功能資料' 
                        ,width: 600
                        , resizable: false
                        , modal: true
                    });
                },
            error : function(XMLHttpRequest, textStatus, errorThrown){
                    $("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
                    $("#ajaxErrorMessageDiv" ).dialog( "destroy" );
                    $("#ajaxErrorMessageDiv" ).dialog({  
                        title:'系統錯誤' 
                        ,width: 600
                        , resizable: false
                        , modal: true
                        , buttons: {
                            Ok: function() {
                                $( this ).dialog( "close" );
                            }
                        }
                    });
                },
            complete: function(XMLHttpRequest, textStatus){closeWaitingDialog();}
        });
                
    }    
    //-->
    </script>
</head>
<body>
<div id="mainAreaCT">
        <jsp:include page="/includes/path.jsp"/>
        <jsp:include page="/includes/subMenu.jsp"/>
        
    <div id="roleFormDiv">
        <stripes:form id="roleFrom" beanclass="com.feib.soeasy.action.Soez9003ActionBean" method="post">
                 
            <table id="queryForm">
                <tr>
                    <th>程式類別</th>
                    <td>
                        <stripes:select id="menuType" name="menuType" >
                            <stripes:option value="0">程式群組</stripes:option>
                            <stripes:option value="1">程式功能</stripes:option>
                        </stripes:select>
                    </td>
                </tr>
                <tr>
                    <th>程式代號</th>
                    <td>
                        <stripes:text id="menuId" name="menuId" size="15" maxlength="30" />
                    </td>
                </tr>
                <tr>
                    <th>程式名稱</th>
                    <td>
                        <stripes:text id="actionName" name="actionName" size="15" maxlength="50" />
                    </td>
                </tr>                                
                <tr>
                    <td colspan="2" class="queryFunction">
                        <stripes:button id="doQueryBtn" name="doQueryBtn" value="查詢" class="formBtn"/>
                        <stripes:button id="doAddBtn" name="doAddBtn" value="新增" class="formBtn"/>
                    </td>
                </tr>
            </table>
        </stripes:form>
    </div>  
    
    <!-- 權限功能查詢結果  -->
    <div id="queryResultDiv" style="display: none;">
    </div>    
    <div id="queryHiddenFormDiv" style="display: none;">
        <stripes:form id="queryHiddenFrom" beanclass="com.feib.soeasy.action.Soez9003ActionBean" 
            method="post" onsubmit="javascript: return false;">
            <stripes:hidden id="hidden.menuType" name="menuType" />
            <stripes:hidden id="hidden.menuId" name="menuId" />
            <stripes:hidden id="hidden.actionName" name="actionName"/>
            <stripes:hidden id="hidden.queryResult.pageNumber" name="queryResult.pageNumber" />         
                        
            <input type="hidden" id="method1" name="doAjaxQuery"/>
        </stripes:form>
    </div>    
    
    <!-- 功能明細查詢 -->
    <div id="menuItemDiv" style="display: none;">
    </div>
    <div id="queryMenuHiddenFormDiv" style="display: none; ">
        <stripes:form id="queryMenuHiddenFrom" beanclass="com.feib.soeasy.action.Soez9003ActionBean" 
            method="post" onsubmit="javascript: return false;">         
            <stripes:hidden id="hidden.menuItemPk" name="menuItemPk"/>       
            <input type="hidden" id="method2" name="doAjaxQueryMenuItem"/>
        </stripes:form>
    </div>    
    
    <div id="addMenuHiddenFormDiv" style="display: none; ">
        <stripes:form id="addMenuHiddenFrom" beanclass="com.feib.soeasy.action.Soez9003ActionBean" 
            method="post" onsubmit="javascript: return false;">                
            <input type="hidden" id="method3" name="doAjaxAddMenuItem"/>
        </stripes:form>
    </div> 
    <!-- Message -->
	<div id="ajaxErrorMessageDiv" style="display: none;"></div>       
</div>    
</body>
</html>          